namespace ScrumSprintMonitor.UI.Wpf.Converters
{
	#region #using Directives

	using System;
	using System.Collections;
	using System.Globalization;
	using System.Windows.Controls;
	using System.Windows.Data;

	#endregion

	public class LegendBrushValueConverter : IMultiValueConverter
	{
		#region IMultiValueConverter Members

		public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
		{
			if (values != null && values.Length == 3 && values[1] is IList && values[2] is UserControl)
			{
				var obj = values[0];
				var list = (IList) values[1];
				var chartLegend = (UserControl) values[2];

				return chartLegend.FindResource(string.Format("LegendBrush{0}", list.IndexOf(obj)));
			}

			return null;
		}

		public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}